<?php
namespace Admin\Controller;
class AdminIndexController extends BaseController {
    //后台首页管理员管理
    public function index(){
/*         $SelectAdmin = M('admin');
        $data = I('post.');
        $offset = ($data['page'] - 1) * $data['rows'];
        $select =  $SelectAdmin->where("username=".$data['username'])
                                            ->limit($offset,$data['rows'])
                                            ->field("id,username,email")
                                            ->select();
        $this->assign(name,$select); */
        $SelectAdmin = M('admin');
        $data = I('post.');
        $offset = ($data['page'] - 1) * $data['rows'];
        $rs = $SelectAdmin->select();
        $this->assign('rs',$rs);
        $this->display();
    }
    /*
     * 删除数据
     */
    public function Dell(){
        $Dell = M('admin');
        $data = I('post.');
        $rs = $Dell->delete($data['id']);
        if(!empty($rs)){
            $array = array('status'=>"1",'info'=>"删除成功",'url'=>U('AdminIndex/index'));
        }else{
            $array = array('status'=>"0",'info'=>"删除失败",'url'=>U('AdminIndex/index'));
        }
        $this->ajaxReturn($array);
    }
    public function xiugai(){
        $xiugai =  M('admin');
        $data = I('get.');
        $rs = $xiugai->where($data)->select();
        if (!empty($rs)){
            $this->assign('rs',$rs);
        }
        $this->display();
    }
    public function doXiugai(){
        $doXiugai =  M('admin');
        $data = I('post.');
        $rs = $doXiugai->save($data);
        if(!empty($rs)){
            $array = array('status'=>"1",'info'=>"修改成功",'url'=>U('AdminIndex/index'));
        }else{
            $array = array('status'=>"0",'info'=>"修改失败",'url'=>U('AdminIndex/index'));
        }
        $this->ajaxReturn($array);
    }
}